#include <iostream>
using namespace std;

#include<string>
int main()
{
	string s,t;
	cin >> s >> t;
	int n = 0;
	cin >> n;
	while(n--)
	{
		int l1 = 0,r1 = 0,l2 = 0,r2 = 0;
		cin >> l1 >> r1 >> l2 >> r2;
		string s1 = s.substr(l1-1,r1-l1);
		string t1 = s.substr(l2-1,r2-l2);
		
		if(s1 == t1)
		{
			cout << "vovo" << endl;
		} 
		else if(s1 < t1)
		{
			cout << s1 <<endl;
		}
		else
		{
			cout << t1 << endl;
		}
	}
	return 0;
}
